library(ggplot2)

dfca<-read.csv("1L2_Ca_titration.csv")

#create line plot
ggplot(dfca, aes(x=Concentration, y=Mean_RelativeActivity, color = Sample, group = Sample)) +
  geom_line(size=0.6, show.legend = F)+
  geom_point(aes(shape=Sample, color=Sample), size=3, show.legend = T)+
  scale_color_manual(values= c("darkorange2","goldenrod1", "goldenrod3"), labels=c(expression(paste("0"~"mM"~"Mg"^"2+")), expression(paste("1"~"mM"~"Mg"^"2+")), expression(paste("3"~"mM"~"Mg"^"2+"))))+
  scale_shape_manual(values=c(16, 17, 15), labels=c(expression(paste("0"~"mM"~"Mg"^"2+")), expression(paste("1"~"mM"~"Mg"^"2+")), expression(paste("3"~"mM"~"Mg"^"2+"))))+
  geom_errorbar(data = dfca, aes(ymin=Mean_RelativeActivity-StDev, ymax=Mean_RelativeActivity+StDev), width=0.2) +
  theme_minimal() +
  labs(
    title = "Divalent cations titration",
    x = expression(paste("[Ca"^"2+"*"]"~"(mM)")),
    y = "Relative DNase activity (%)"
  )+
  theme(axis.text.x = element_text(size = 16), axis.text.y = element_text(size = 16), 
        axis.title.y = element_text(size=20), axis.title.x = element_text(size=20), 
        title = element_text(size = 16), 
        legend.title = element_blank(), legend.text = element_text(size=16), 
        legend.position = c(0.7, 0.58), legend.key.height = unit(0.75, "cm"), 
        plot.margin = margin(0.5, 0.5, 0.5, 0.5, "cm"))

ggsave("Ca_titration.pdf", width = 17, height = 15, units = "cm")
